package org.sockettest.client;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.Socket;

public class ReaderThread implements Runnable  {
    private final Socket socket;
    public ReaderThread(Socket socket) {
        this.socket = socket;
    }


    @Override
    public void run() {
        try(BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()))){
            while (true){

                String str = reader.readLine();
                System.out.println("From Server:");
                System.out.println(str);
                if(str == null){
                    break;
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
